#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/wait.h>


int main()
{
  int fd; //, fd_old;
  
  printf("test\n");

  dup2(1, 4);
  
  int rc = fork();
  
  if (rc == 0) {
    printf("Child: Got There.\n");
    close(1);
    
    fd = open( "newfile.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600 );

    printf("stuff\n");
    return 0;
  }
  else {
    wait(NULL);
  }
  
  dup2(4, 1); //fd_old,1);
  
  printf("test\n");
  
  return 0;

}
